<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">
    hello
  </div>
  <script>
    let data = {
      msg: 'Hello'
    };
    let vm = {};
    Object.defineProperty(vm, 'msg', {
      enumerable: true,
      configurable: true,
      get() {
        console.log('getter', data.msg);
        return data.msg
      },
      set(newValue) {
        console.log('setter', newValue);
        if (newValue === data.msg) return;
        data.msg = newValue;
        document.getElementById('app').textContent = data.msg;
      }
    })
  </script>
</body>

</html>